package com.web.tasks;


import java.util.Calendar;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.web.common.Sys;

/**
 * 刷新两面长龙定时任务
 * 
 * @author yangzhongying mail:223450427@qq.com
 * @date 2016-12-13 下午02:29:40
 * @package com.web.tasks
 */
@Component
public class RefreshDoubleTopTask extends AbstractTask {

	@Resource(name = "sys")
	private Sys sys;
	private Calendar cal;

	protected RefreshDoubleTopTask() {
		super("Double top Task", true);
	}

	//每半个小时执行一次刷新字典缓存
	@Override
	@Scheduled(cron = "0 0/30 * * * ? ")
	public void taskEntrance() {
		super.taskEntrance();
	}

	@Override
	protected void executeTask() {
		cal = Calendar.getInstance();
		int currH = cal.get(Calendar.HOUR_OF_DAY);
		// 没结果时间段
		if (currH > 0 && currH < 9) {
			logger.info("休息时段，不请求结果");
			return;
		}
		sys.loadTerm();
	}

	@PostConstruct
	public void init() {
		logger.info("项目启动执行一次");
		sys.loadTerm();
	}

}
